/*
	The MIT License

	Copyright (c) 2008 IFMO/GameDev Studio

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/
// d3d_local.h - should be included in all rend_d3d`s cpp files

#pragma once

#pragma once


#ifdef _DEBUG
	#define D3D_DEBUG_INFO
#endif

#define D3D_DEBUG_INFO

#include <d3d9.h>
#include <d3dx9.h>

#define	WIN32_LEAN_AND_MEAN
#define	VC_EXTRALEAN
#include <windows.h>

#undef DLL_EXPORT
#undef DLL_IMPORT
#if 1
	#define	DLL_EXPORT	extern "C"	__declspec(dllexport)
	#define	DLL_IMPORT	extern "C"	__declspec(dllimport)
#else
	#define	DLL_EXPORT
	#define	DLL_IMPORT
#endif


#pragma comment (lib, "d3dxof.lib")
#pragma comment (lib, "dxguid.lib")
#pragma comment (lib, "d3dx9.lib")
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "winmm.lib")

/*-----------------------------------------------------------------------------
	Quake II headers :
-----------------------------------------------------------------------------*/
//#include "..\game\q_shared.h"
//#include "..\client\ref.h"
//
//extern refimport_t	ri;
extern class ED3DRenderSystem *rs;
//
/*-----------------------------------------------------------------------------
	Eclipse libraries :
-----------------------------------------------------------------------------*/
//#include "..\tinyxml\tinyxml.h"
#include "..\global.h"
#include "..\library\library.h"

extern IConsole		*con;
extern IShell		*shell;
extern IFileSystem	*fs;
//#include "profiler.h"
//
//#include "q2_facade.h"


//#define _PROFILE
//
//#ifdef _PROFILE
//	extern EProfiler profiler;
//	#define PROF_BEGIN_EVENT(s)		profiler.BeginEvent(s)
//	#define PROF_END_EVENT()		profiler.EndEvent()
//
//	#define PROF_PROBE()			EProfProbe __prof_probe__(&profiler, __FUNCTION__)
//	#define PROF_COUNT_FRAME_TIME()	profiler.CountFrameTime();
//#endif

//extern EVidProfiler	*vid_profiler;

//class EVidProfProbe {
//	public:
//		EVidProfProbe	( const char *name ) {
//			
//			WCHAR str[256];
//			MultiByteToWideChar(CP_OEMCP, MB_PRECOMPOSED, name, (int)(strlen(name)+1), str, 255);
//
//			D3DPERF_BeginEvent(0xFFFFFFFF, str);
//		}
//		~EVidProfProbe	( void ) {
//			D3DPERF_EndEvent();
//		}
//	protected:
//	};
//
//#define VID_PROF_PROBE()			EVidProfProbe __vid_prof_probe__(__FUNCTION__)


/*-----------------------------------------------------------------------------
	Direct3D rendering driver structures :
-----------------------------------------------------------------------------*/

//typedef struct image_s {
//		image_s (void) {
//			memset(this, 0, sizeof(image_s));
//		}
//		char		name[MAX_QPATH];
//		uint32_t	width;
//		uint32_t	height;
//		EVec4		average_color;
//		D3DXIMAGE_INFO			image_info;	
//		IDirect3DBaseTexture9	*d3d_tex;
//		
//		EVec4	GetAverageColor	( void ) const;
//		
//		bool	HasAlpha		( void ) const {
//			if (image_info.Format==D3DFMT_A8R8G8B8) return true;
//			return false;
//		}
//	} image_t;
//
//
//struct	model_s {
//		virtual			~model_s	(void) { }
//		virtual	void	DrawModel	(const entity_t *ent) = 0;
//		virtual bool	IsHull			( void ) const { return false; }
//		char	name[MAX_QPATH];
//	};


#define CHECK_CRITICAL(expr) if (FAILED(expr)) { SYS_Error(ERR_FATAL, va("%s() : %s failed", __FUNCTION__, #expr)); }

#define SAFE_RELEASE(obj) if (obj) { obj->Release(); }

/*-----------------------------------------------------------------------------
	Local D3D RS headers :
-----------------------------------------------------------------------------*/

//#include "palette.h"
//#include "d3d_shaders.h"
//#include "d3d_materials.h"
//#include "d3d_models.h"
//#include "d3d_rt_mgr.h"
//#include "d3d_gfx.h"
//#include "d3d_lighting.h"
//#include "d3d_def_rend.h"
//#include "d3d_hdr.h"
#include "d3d_render_system.h"
#include "cuda_test.h"
#include "cuda_test_mri.h"










